package test;

/**
 * @Author Stringzhua
 * @Date 2024/11/7 23:05
 * description:
 */
public class Demo01 {
    public static void main(String[] args) {
//        String str = "abccba";
//		String str = "abcdcba";
        String str = "abcddadadcba";
        System.out.println(check(str));
    }

    public static boolean check(String s) {
        int left = 0;//左指针
        int right = s.length() - 1;//右指针
        //如果left小于right,就比较一下大小
        while (left < right) {
            //将左右指针的字符比较
            if (s.charAt(left) != s.charAt(right)) {
                return false;
            }
            //相等...左指针右移,右指针左移
            left++;
            right--;
        }
        return true;
    }
}

